fix: Refuse to overwrite foreign objects from TrustStore reconciler - #707
Conversation
b3fc25f to
5b555d9
Compare
5b555d9 to
940dde4
Compare
sweb
left a comment
There was a problem hiding this comment.
lgtm - but I primarily did this to dive into the code base, so grains of salt - I also tried out the review skill on this.
NickLarsenNZ
left a comment
There was a problem hiding this comment.
This looks ready to merge.
|
Merged cancelled due to a comment from @sbernauer
|
|
https://github.com/cert-manager/cert-manager has a similar problem but less severe (keys in Secrets/ConfigMaps are fixed and can't be chosen by an attacker), but https://github.com/cert-manager/trust-manager has the same problem. That does not mean we can't do it better though. We have discovery ConfigMaps in other operators, but that problem is limited to ConfigMaps and the keys are fixed there as well. This problem in secret-operator is more severe since it allows overwriting ConfigMaps and Secrets and the keys can be chosen freely (at least not the content, but still a more severe problem, see the For Listeners, a user can override/delete any Service in the namespace that he can create Listeners in. That is similar to the problem this PR fixes and could be fixed as well. I did not find any similar problems. We have three options: The real security benefit is probably not too high (having permissions to create TrustStores / Listeners is a requirement to exploit this) but it also should not break anything or make it much worse. I'm leaning towards option a) since it fixes the two worst problems and the blast radius is limited. @sbernauer what's your opinion on this? |
sbernauer
left a comment
There was a problem hiding this comment.
Sure, I let you decide, ship it :)
|
Should this have a release note? |
I don't think so, this should not affect customers in any way, it just strengthens the basic security of SDP a bit. |
Description
TLDR: Write access on
TrustStoreallows write access forConfigMaporSecretin the same namespaceThe TrustStore reconciler writes its output
ConfigMaporSecretusing theTrustStoreCR's own name and applies it via SSA withforce=true. Combined with the operator's cluster-wide write permissions onConfigMapsandSecrets, this lets any principal who can create aTrustStorein a namespace cause the operator to overwrite the contents of any pre-existing same-namedConfigMaporSecretin that namespace, stealing ownership and attaching a controllerOwnerReferencethat links the hijacked object to theTrustStoreCR for cascade delete.A good showcase is the auto-published
kube-root-ca.crtConfigMap:A tenant with
createontruststores.secrets.stackable.techin their namespace can create a TrustStore namedkube-root-ca.crt, overwrite the CA bundle every pod in the namespace uses to verify in-cluster TLS, and cascade-delete that ConfigMap by deleting the TrustStore. This allows a) MITM attacks (hard because you need to modify DNS resolution of the Pods) and b) potentially crashing existing Pods on restart becausekube-root-ca.crtis corrupted.The same applies to any
ConfigMaporSecretin the same namespace whose name the attacker can guess.Fix
Before applying, look up the existing target. If the object already exists and is not owned by the current
TrustStore, refuse the reconciliation.Definition of Done Checklist
Author
Reviewer
Acceptance
type/deprecationlabel & add to the deprecation scheduletype/experimentallabel & add to the experimental features tracker